const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let n;
let initArr = [];
rl.on("line", (line) => {
    if (n === undefined) {
        n = Number(line.trim())
    } else {
        initArr.push(line.trim().split(" ").map(Number))
        if (initArr.length === n) {
            console.time("a")
            initArr.forEach(arr => console.log(getResult(arr.shift(), arr)))

            // clear
            n = undefined;
            initArr.length = 0
            console.timeEnd("a")
        }
    }

})
function getResult(n, arr) {
    arr.sort((a, b)=> a - b)

    // 首先通过dfs, 计算所有的三角形组合
    let res = []
    dfs(arr, 0, res, [])

    // 统计
     let obj = {}
    for (const num of arr) {
        if(obj[num] === undefined) {
            obj[num] = 1
        } else {
            obj[num]++
        }
    }

    let result = []
    // 然后暴力, 算各种组合, 对应的匹配数量
    backTrack(res, 0, 0, result, obj)
    return Math.max(...result)

}


function backTrack(res, start, count, result, obj) {
    if(start === res.length){
        result.push(count)
        return
    }

    for (let i = start; i < res.length ; i++) {
        const [a, b, c] = res[i]
        if(obj[a] && obj[b] && obj[c]) {
            obj[a]--
            obj[b]--
            obj[c]--
            backTrack(res, i + 1, count+1, result, obj )
            obj[a]++
            obj[b]++
            obj[c]++
        }
    }
}


function dfs(arr, start, res, path) {
    if(path.length === 3) {
        if(valid(path)) {
            res.push([...path])
        }
        return
    }
    //if(start === arr.length) return;

    for (let i = start; i < arr.length ; i++) {
        path.push(arr[i])
        dfs(arr, start + 1, res, path)
        path.pop()
    }

}

function valid(arr) {
    const [a, b, c] = arr
    return a*a + b*b === c*c
}